//
//  GetLuckyMoneyListCell.m
//  meiyinxiang
//
//  Created by apple on 2017/11/10.
//  Copyright © 2017年 hbjApple. All rights reserved.
//

#import "GetLuckyMoneyListCell.h"
#import "UIImage+Category.h"
#import "MYXRecommendDetailController.h"
@interface GetLuckyMoneyListCell (){
}
@property (weak, nonatomic) IBOutlet UIImageView *iconImageView;
@property (weak, nonatomic) IBOutlet UILabel *nameLable;
@property (weak, nonatomic) IBOutlet UILabel *timeLable;
@property (weak, nonatomic) IBOutlet UILabel *replyLabel;
@property (weak, nonatomic) IBOutlet UILabel *moneyLabel;
@property (weak, nonatomic) IBOutlet UILabel *moreCommendLabel;

@end
@implementation GetLuckyMoneyListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.iconImageView.contentMode = UIViewContentModeScaleAspectFill;
    self.iconImageView.layer.cornerRadius = 18;
    self.iconImageView.layer.masksToBounds = YES;

}

- (void)setDetailModel:(MYXRecieveMoneyListViewModel *)detailModel{
    if (detailModel.iconImg) {
        self.iconImageView.image = detailModel.iconImg ;
    }else{
        [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",MYXIMGBaseUrl,detailModel.userface]] placeholderImage:[UIImage imageNamed:@"AppIcon"] options:SDWebImageCacheMemoryOnly completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
            if (image) {
                detailModel.iconImg = image;
                self.iconImageView.image = detailModel.iconImg;
               // self.iconImageView.image = image;
            }else{
                self.iconImageView.image = [UIImage imageNamed:@"AppIcon"];
            }
        }];        
    }
    if (detailModel.showMoreComendLabel == YES) {
        self.moreCommendLabel.hidden = NO;
        self.moreCommendLabel.text = detailModel.count;
    }else{
        self.moreCommendLabel.hidden = YES;
    }
    self.nameLable.text = detailModel.username;
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:detailModel.pick_time.integerValue];
    NSDateFormatter*dateFormatter = [[NSDateFormatter alloc]init];
    
    //设定时间格式,这里可以设置成自己需要的格式
    
    [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    
    NSString*currentDateStr = [dateFormatter stringFromDate:date];
    
    self.timeLable.text = currentDateStr;
    self.replyLabel.text = detailModel.content;
    self.moneyLabel.text = [NSString stringWithFormat:@"%@元",detailModel.num];
    
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
   
    // Configure the view for the selected state
    
}

+(GetLuckyMoneyListCell *)loadNibWithListCell{
    UINib *nib = [UINib nibWithNibName:@"GetLuckyMoneyListCell" bundle:[NSBundle mainBundle]];
    return [[nib instantiateWithOwner:nil options:nil]lastObject];
}

@end
